package com.prp.gwt.client.widgets.user.article;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.prp.gwt.client.user.article.ArticleListener;
import com.prp.gwt.client.vo.SubjectRecommendList;

public class SystemTopRecommendPanel extends VerticalPanel{
	
	private static SystemTopRecommendPanel instance;
	private VerticalPanel innerPanel = new VerticalPanel();
	private Image loadImage = new Image(GWT.getModuleBaseURL() + "loading.gif");
	private static Grid table = new Grid(3, 3);
	
	public static SystemTopRecommendPanel getInstance(){
		return instance;
	}
	
	public SystemTopRecommendPanel(){
		instance = this;
		HTML title = new HTML("热门主题贴");
		title.addStyleName("systemTopRecommend-title");
		innerPanel.add(title);
		innerPanel.add(loadImage);
		innerPanel.add(table);
		add(innerPanel);
		ArticleListener.getInstance().getTopRecommend();
	}
	
	public void loadRecommendationList(SubjectRecommendList list){
		loadImage.setVisible(false);
		for (int i = 0; i < list.size() && i < 9; i++)
			table.setWidget(i / 3, i % 3, new RecommendSummaryItem(list.get(i)));
	}
	
}
